<?php
if(isset($_POST["save-project"]))
{
$company 	= $_POST["company"];
$contact 	= $_POST["contact"];
$costs   	= $_POST["costs"];
$cpc	 	= $_POST["cpc"];
$samplesize = $_POST["samplesize"];
$complete   = $_POST["complete"];
$screenout	= $_POST["screenout"];
$url	 	= $_POST["url"];
$extra1	 	= $_POST["extra1"];
$extra2	 	= $_POST["extra2"];
$quotafull	= $_POST["quotafull"];
$id 	 	= $_POST["id"];
$key1		= $_POST["key1"];
$key2		= $_POST["key2"];
$pname		= $_POST["projectname"];

unset($_POST["save-project"]);

$query =  "update ghostprojects set costs =\"$costs\", cpc = \"$cpc\", samplesize = \"$samplesize\", 
url = \"$url\", complete = \"$complete\", screenout = \"$screenout\", quotafull = \"$quotafull\", 
extra1 = \"$extra1\", extra2 = \"$extra2\", key1 = \"$key1\", key2 = \"$key2\", projectname = \"$pname\" where id=$id";
	$db = mysql_connect("mysql513.in.shared-server.net:16033", "JRtu434", "qvoiceDB1");
	mysql_select_db("JRtu434", $db);
	mysql_query("set SQL_BIG_Selects=1");
	mysql_query("SET NAMES utf8");
	mysql_query(strip_tags($query));
	mysql_close;
}
else if(isset($_POST["new-project"]))
{
	unset($_POST["new-project"]);
	$db = mysql_connect("mysql513.in.shared-server.net:16033", "JRtu434", "qvoiceDB1");
	mysql_select_db("JRtu434", $db);
	mysql_query("insert into ghostprojects () values ()");
	$result = mysql_query("select max(id) from ghostprojects");
	$record = mysql_fetch_array($result);
	$_POST["id"] = $record[0];
	mysql_close;
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html lang="ja"> 
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
	var bindbehaviors = function(scope) 
	{		 		
		$(".navbutton").click(function()
		{
			$("#content").load("dynamic.php?func=9&id="+$(this).val(),function() 
			{
 				bindbehaviors(this);
	 		});
		});
		$("#id-toggle").click(function()
		{
			$("#ids").load("dynamic.php?func=10&id="+$(this).val(),function() 
			{
 				bindbehaviors(this);
	 		});
		});
	};
	bindbehaviors(this);
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<meta http-equiv="Content-Style-Type" content="text/css"> 
<meta http-equiv="Content-Script-Type" content="text/javascript"> 
<title>Ghost Projects</title>
	</head>
	<?php include "layout.php"; ?>
		<div id="content">
			<div id="change">
				<?php include "dynamic.php"; isset($_POST["id"])?ghostproject($_POST["id"]):ghostproject("1");?></div>
			</div>
		</div>
	</body>
</html>